package com.yuxi.controller;

import org.apache.commons.lang.time.DateFormatUtils;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

import java.util.Date;

/**
 * 定时器
 * Created by yuxi on 16/10/27.
 */
@Component
public class CronTestController {
    int i = 0;

//    @Scheduled(cron = "${job.everysecond.cron}")
    public void cronTest() {
        System.out.println("第" + (++i) + "次调用，每秒任务，当前时间：" + nowTime());
    }

    private String nowTime() {
        return DateFormatUtils.format(new Date(),"yyyy-mm-hh HH:mm:ss");
    }
}
